console.log('启动演练', $event);
const $list = this.pageObj.getApiWidgetByAliasName('list')?.widgetObj;
// 变量
let params = this.pageObj.getVariables().find(v => v.name === "screen_params")?.value;
const prefix = this.pageObj.getVariables().find(v => v.name === "environmentType")?.value;

try {
  // 路由参数
  params = params ? JSON.parse(params) : {
    id: '1765642885643964417',
    eventType: '1742818710932074497',
    eventLevel: '1692442354007216130',
  };
} catch (error) {
  console.error(error)
}

function baseFetch(url, params) {
  return fetch(url, {
    method: 'POST',
    headers: { "Content-type": "application/json" },
    body: JSON.stringify(params),
  }).then(res => res.json())
}

if ($list) {
// 演练数据
  const { emergencyGroup, ...resData } = $list?.getStartUpParams();
  const options = {
    ...params,
    emergencyResource: JSON.stringify(resData),
    // 演练组织典信息
    drillPersonInfoDictTreeNode: $list.getGroupData(),
    eventId: params.eventId || params.id,
    eventType: params.eventType,
    eventLevel: params.eventLevel,
    disableFlag: 2,
  };

  console.log('save', { emergencyGroup, ...resData }, options);
  baseFetch(`/${prefix}Event/drillPlanInfo/update`, options).then(({ success }) => {
    if (success) {
      console.log('save');
      window.layer?.msg('启动成功');
      this.getApiPage().navigateStage('833630884086153216', [{ name: 'screen_params', value: JSON.stringify(options) }])
    }
  });
}
